package view;

import Commom.Constants;
import DAO.ClassDAO;
import DAO.CourseDAO;
import DAO.CousreSubjectDAO;
import DAO.ScheduleDAO;
import DAO.StudentDAO;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.table.DefaultTableModel;
import model.ClassModel;
import model.Course;
import model.CourseSubject;
import model.Schedule;
import model.Staff;
import model.Student;
import model.Subject;

public class ViewStaff extends javax.swing.JFrame {
    public ViewStaff() {
        initComponents();
        myinit();
        lblStaffName.setText(Constants.getStaff().getFullName());
        loadTableStudent();
        setCbbClass();
//        loadSchedule();
        loadCbbCourse();
        loadCbbCourseSchedule();
        loadCbbCourseAtt();

    }
    private void myinit() {
        setLocationRelativeTo(null);
        jtabbed.setBackgroundAt(0, Color.decode("#cccccc"));
        this.getContentPane().setBackground(new Color(94, 91, 91));
        setTabIcon("Home", "../image/home.png", 0);
        setTabIcon("Course Schedule", "../image/course.png", 1);
        setTabIcon("Student", "../image/student.png", 2);
        setTabIcon("Class Schedule", "../image/class.png", 3);
        setTabIcon("Attendance", "../image/session.png", 4);
        setTabIcon("Fine", "../image/fine.png", 5);
    }

    private void setTabIcon(String title, String image, int tab) {
        JLabel lbl = new JLabel(title);
        Icon icon = new ImageIcon(getClass().getResource(image));
        lbl.setIcon(icon);
        lbl.setIconTextGap(5);
        lbl.setForeground(Color.BLACK);
        lbl.setFont(new Font("Courier New", Font.PLAIN, 16));
        lbl.setHorizontalTextPosition(SwingConstants.RIGHT);
        jtabbed.setTabComponentAt(tab, lbl);
    }

    public void setCbbClass() {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        List<ClassModel> list = new ArrayList<ClassModel>();
        list = ClassDAO.getAll();
        model.addElement("All Class");
        for (ClassModel cr : list) {
            model.addElement(cr);
        }
        cbbClass.setModel(model);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jtabbed = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jPanel16 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel30 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        btnViewCourse = new javax.swing.JButton();
        btnDeleteCourse = new javax.swing.JButton();
        btnModifyCourse = new javax.swing.JButton();
        btnAddCourse = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        txtSearchCourse = new javax.swing.JTextField();
        cbbFilterCourse = new javax.swing.JComboBox();
        jComboBox4 = new javax.swing.JComboBox();
        btnSearchCourse = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblCourse = new javax.swing.JTable();
        cbbCourseSchedule = new javax.swing.JComboBox();
        jPanel12 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        btnAddCourse2 = new javax.swing.JButton();
        btnViewCourse2 = new javax.swing.JButton();
        btnDeleteCourse2 = new javax.swing.JButton();
        btnModifyCourse2 = new javax.swing.JButton();
        jPanel14 = new javax.swing.JPanel();
        jTextField4 = new javax.swing.JTextField();
        jComboBox7 = new javax.swing.JComboBox();
        jComboBox8 = new javax.swing.JComboBox();
        jButton19 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblStudent = new javax.swing.JTable();
        cbbClass = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jPanel22 = new javax.swing.JPanel();
        cbbSelectCourse = new javax.swing.JComboBox();
        cbbSelectClass = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblClass = new javax.swing.JTable();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jPanel15 = new javax.swing.JPanel();
        jPanel23 = new javax.swing.JPanel();
        cbbSelectCourseAtt = new javax.swing.JComboBox();
        cbbSelectClassAtt = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblClassAtt = new javax.swing.JTable();
        jButton10 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        lblStaffName = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jtabbed.setBackground(new java.awt.Color(255, 255, 255));

        jPanel2.setBackground(Color.decode("#cccccc"));

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jLabel3.setBackground(new java.awt.Color(0, 102, 255));
        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(51, 51, 51));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("About Us");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(51, 51, 51));
        jLabel5.setText("Development Team :");

        jLabel6.setText("Le Quang Trung");

        jLabel7.setText("Mao Chung Thanh");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(51, 51, 51));
        jLabel8.setText("Contact Detail :");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(51, 51, 51));
        jLabel10.setText("Phone :");

        jLabel11.setText("+84 935 066 154");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(51, 51, 51));
        jLabel12.setText("Email :");

        jLabel13.setText("letrung193@gmail.com");

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/aptech.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(28, 28, 28)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(60, Short.MAX_VALUE))
            .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jLabel6)
                .addGap(11, 11, 11)
                .addComponent(jLabel7)
                .addGap(44, 44, 44)
                .addComponent(jLabel8)
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(11, 11, 11)
                        .addComponent(jLabel10))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(jLabel11)))
                .addGap(26, 26, 26)
                .addComponent(jLabel9)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(51, 51, 51));
        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("Welcome to AITSM Staff System");

        jPanel16.setBackground(new java.awt.Color(204, 204, 204));
        jPanel16.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton2.setForeground(new java.awt.Color(51, 51, 51));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/password.png"))); // NOI18N
        jButton2.setText("Change password");
        jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton3.setForeground(new java.awt.Color(51, 51, 51));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/logout.png"))); // NOI18N
        jButton3.setText("Log out");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel30.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel30.setForeground(new java.awt.Color(51, 51, 51));
        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel30.setText("You're currently login as an Staff");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel30, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(18, 18, 18)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                .addComponent(jLabel30)
                .addGap(31, 31, 31))
        );

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 577, Short.MAX_VALUE)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(91, 91, 91)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel15)
                .addGap(38, 38, 38)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(71, Short.MAX_VALUE))
        );

        jtabbed.addTab("tab1", jPanel2);

        jPanel3.setBackground(Color.decode("#cccccc"));

        jPanel9.setBackground(new java.awt.Color(255, 255, 255));
        jPanel9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        btnViewCourse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/view.png"))); // NOI18N
        btnViewCourse.setText("View Course");
        btnViewCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewCourseActionPerformed(evt);
            }
        });

        btnDeleteCourse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/delete.png"))); // NOI18N
        btnDeleteCourse.setText("Delete Course");
        btnDeleteCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteCourseActionPerformed(evt);
            }
        });

        btnModifyCourse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/edit.png"))); // NOI18N
        btnModifyCourse.setText("Modify Course");
        btnModifyCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModifyCourseActionPerformed(evt);
            }
        });

        btnAddCourse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/add.png"))); // NOI18N
        btnAddCourse.setText("Add Course Schedule");
        btnAddCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddCourseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAddCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDeleteCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(btnViewCourse, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnModifyCourse, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(btnAddCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(btnModifyCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(btnViewCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(btnDeleteCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(177, Short.MAX_VALUE))
        );

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        cbbFilterCourse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Course ID", "Course Name", "Subject ID", "Subject Name", "Year", "Hour Per Week", " " }));

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ASC", "DESC" }));

        btnSearchCourse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/search.png"))); // NOI18N
        btnSearchCourse.setText("Search / Sort");
        btnSearchCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchCourseActionPerformed(evt);
            }
        });

        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/refresh.png"))); // NOI18N
        jButton16.setText("Refresh");

        jLabel1.setText("Filter :");

        jLabel2.setText("Sort :");

        jLabel14.setText("Keyword :");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtSearchCourse, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                .addGap(10, 10, 10)
                .addComponent(jLabel1)
                .addGap(2, 2, 2)
                .addComponent(cbbFilterCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSearchCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(txtSearchCourse)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbbFilterCourse)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox4)
                    .addComponent(btnSearchCourse, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton16)
                    .addComponent(jLabel14))
                .addContainerGap())
        );

        tblCourse.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Course ID", "Course Name", "Subject ID", "Subject Name", "Year", "Hour Per Week"
            }
        ));
        jScrollPane4.setViewportView(tblCourse);
        if (tblCourse.getColumnModel().getColumnCount() > 0) {
            tblCourse.getColumnModel().getColumn(0).setResizable(false);
            tblCourse.getColumnModel().getColumn(1).setResizable(false);
            tblCourse.getColumnModel().getColumn(2).setResizable(false);
            tblCourse.getColumnModel().getColumn(3).setResizable(false);
            tblCourse.getColumnModel().getColumn(4).setResizable(false);
            tblCourse.getColumnModel().getColumn(5).setResizable(false);
        }

        cbbCourseSchedule.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbbCourseSchedule.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbCourseScheduleItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(cbbCourseSchedule, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cbbCourseSchedule, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        jtabbed.addTab("tab2", jPanel3);

        jPanel13.setBackground(new java.awt.Color(255, 255, 255));
        jPanel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        btnAddCourse2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/add.png"))); // NOI18N
        btnAddCourse2.setText("Add Student");
        btnAddCourse2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddCourse2ActionPerformed(evt);
            }
        });

        btnViewCourse2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/view.png"))); // NOI18N
        btnViewCourse2.setText("View Student");
        btnViewCourse2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewCourse2ActionPerformed(evt);
            }
        });

        btnDeleteCourse2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/delete.png"))); // NOI18N
        btnDeleteCourse2.setText("Delete Student");
        btnDeleteCourse2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteCourse2ActionPerformed(evt);
            }
        });

        btnModifyCourse2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/edit.png"))); // NOI18N
        btnModifyCourse2.setText("Modify Student");
        btnModifyCourse2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModifyCourse2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnDeleteCourse2, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(btnViewCourse2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnModifyCourse2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                        .addComponent(btnAddCourse2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(btnAddCourse2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addComponent(btnModifyCourse2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(btnViewCourse2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(btnDeleteCourse2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(177, Short.MAX_VALUE))
        );

        jPanel14.setBackground(new java.awt.Color(255, 255, 255));
        jPanel14.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID", "name" }));

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ASC", "DESC" }));

        jButton19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/search.png"))); // NOI18N
        jButton19.setText("Search / Sort");

        jButton20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/refresh.png"))); // NOI18N
        jButton20.setText("Refresh");

        jLabel19.setText("Filter :");

        jLabel20.setText("Sort :");

        jLabel21.setText("Keyword :");

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                .addGap(10, 10, 10)
                .addComponent(jLabel19)
                .addGap(2, 2, 2)
                .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton20, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jTextField4)
                    .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox7)
                    .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox8)
                    .addComponent(jButton19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton20)
                    .addComponent(jLabel21))
                .addContainerGap())
        );

        tblStudent.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane6.setViewportView(tblStudent);

        cbbClass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbbClass.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbClassItemStateChanged(evt);
            }
        });

        jLabel22.setText("Class :");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane6)
                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbClass, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbbClass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        jtabbed.addTab("tab4", jPanel12);

        cbbSelectCourse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbbSelectCourse.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbSelectCourseItemStateChanged(evt);
            }
        });

        cbbSelectClass.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbSelectClassItemStateChanged(evt);
            }
        });

        tblClass.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Class ID", "Class Name", "Date "
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblClass);

        jButton4.setText("View Schedule");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Add Schedule");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton7.setText("edit Schedule");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addComponent(jButton5)
                        .addGap(28, 28, 28)
                        .addComponent(jButton7)
                        .addGap(28, 28, 28)
                        .addComponent(jButton4))
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addComponent(cbbSelectCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(cbbSelectClass, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 988, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap(25, Short.MAX_VALUE)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbbSelectCourse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbSelectClass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jButton5)
                    .addComponent(jButton7))
                .addGap(67, 67, 67))
        );

        jtabbed.addTab("tab7", jPanel22);

        cbbSelectCourseAtt.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbbSelectCourseAtt.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbSelectCourseAttItemStateChanged(evt);
            }
        });

        cbbSelectClassAtt.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbSelectClassAttItemStateChanged(evt);
            }
        });

        tblClassAtt.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Class ID", "Class Name", "Date "
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblClassAtt);

        jButton10.setText("View Attendance");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton12.setText("check attendance");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton8.setText("Edit attendcance");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(cbbSelectCourseAtt, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(cbbSelectClassAtt, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 988, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap(25, Short.MAX_VALUE)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbbSelectCourseAtt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbSelectClassAtt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton10)
                    .addComponent(jButton12)
                    .addComponent(jButton8))
                .addGap(67, 67, 67))
        );

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1053, Short.MAX_VALUE)
            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel15Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 464, Short.MAX_VALUE)
            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel15Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        jtabbed.addTab("tab6", jPanel15);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1053, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 464, Short.MAX_VALUE)
        );

        jtabbed.addTab("tab6", jPanel4);

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/school-icon.png"))); // NOI18N
        jLabel4.setText("Andrews Institute of Technical Sciences and Management");

        jPanel1.setBackground(new Color(19, 16, 13));

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/exit.png"))); // NOI18N
        jButton1.setText("Exit");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("Hello,");

        lblStaffName.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblStaffName.setForeground(new java.awt.Color(255, 255, 255));
        lblStaffName.setText("jLabel17");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblStaffName)
                .addGap(75, 75, 75))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(lblStaffName)))
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jtabbed, javax.swing.GroupLayout.PREFERRED_SIZE, 1058, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 1082, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 25, Short.MAX_VALUE))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jtabbed)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        this.dispose();
        new ViewLogin().setVisible(true);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    }//GEN-LAST:event_jButton2ActionPerformed

    private void btnAddCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddCourseActionPerformed
        if (cbbCourseSchedule.getSelectedIndex() != 0) {
            Course crs = (Course) cbbCourseSchedule.getSelectedItem();
            new ViewAddCourseSubject(this, true, crs).setVisible(true);
        } else {
            alert("Select course");
        }

    }//GEN-LAST:event_btnAddCourseActionPerformed

    private void btnDeleteCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteCourseActionPerformed
        int tb = tblCourse.getSelectedRow();
        if (tb == -1) {
            alert("select row");
        } else {
            int cf = JOptionPane.showConfirmDialog(this, "you are sure", "xoa", JOptionPane.YES_NO_OPTION);
            if (cf == JOptionPane.YES_OPTION) {
                int courseId = Integer.parseInt(tblCourse.getValueAt(tb, 0).toString());
                String subjectId = tblCourse.getValueAt(tb, 2).toString();
                boolean a = CousreSubjectDAO.deleteCourseSubject(courseId, subjectId);
                if (a) {
                    alert("Thanh cong");
                    List<CourseSubject> list = CousreSubjectDAO.getAll((Course) tblCourse.getValueAt(tb, 1));
                    loadCourse(list);
                } else {
                    alert("that bai");
                }
            }
        }
    }//GEN-LAST:event_btnDeleteCourseActionPerformed

    private void btnModifyCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModifyCourseActionPerformed
        int tb = tblCourse.getSelectedRow();
        if (tb == -1) {
            alert("You must be select row to edit");
        } else {
            int courseID = Integer.parseInt(tblCourse.getValueAt(tb, 0).toString());
            String courseName = tblCourse.getValueAt(tb, 1).toString();
            Course course = new Course();
            course.setCourseID(courseID);
            course.setCourseName(courseName);
            String subjectID = tblCourse.getValueAt(tb, 2).toString();
            String subjectName = tblCourse.getValueAt(tb, 3).toString();
            Subject sj = new Subject();
            sj.setSubjectId(subjectID);
            sj.setSubjectName(subjectName);
            int year = Integer.parseInt(tblCourse.getValueAt(tb, 4).toString());
            int hour = Integer.parseInt(tblCourse.getValueAt(tb, 5).toString());
            CourseSubject csub = new CourseSubject(course, sj, year, hour);
            new ViewEditCourseSubject(this, true, csub).setVisible(true);
        }
    }//GEN-LAST:event_btnModifyCourseActionPerformed

    private void btnViewCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewCourseActionPerformed
        int tb = tblCourse.getSelectedRow();
        if (tb == -1) {
            alert("You must be select row to edit");
        } else {
            int courseID = Integer.parseInt(tblCourse.getValueAt(tb, 0).toString());
            String courseName = tblCourse.getValueAt(tb, 1).toString();
            Course course = new Course();
            course.setCourseID(courseID);
            course.setCourseName(courseName);
            String subjectID = tblCourse.getValueAt(tb, 2).toString();
            String subjectName = tblCourse.getValueAt(tb, 3).toString();
            Subject sj = new Subject();
            sj.setSubjectId(subjectID);
            sj.setSubjectName(subjectName);
            int year = Integer.parseInt(tblCourse.getValueAt(tb, 4).toString());
            int hour = Integer.parseInt(tblCourse.getValueAt(tb, 5).toString());
            CourseSubject csub = new CourseSubject(course, sj, year, hour);
            new ViewViewCourseSubject(this, true, csub).setVisible(true);
        }
    }//GEN-LAST:event_btnViewCourseActionPerformed

    private void btnAddCourse2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddCourse2ActionPerformed
        new ViewAddStudent(this, true).setVisible(true);
    }//GEN-LAST:event_btnAddCourse2ActionPerformed

    private void btnModifyCourse2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModifyCourse2ActionPerformed
        int tb = tblStudent.getSelectedRow();
        if (tb == -1) {
            alert("select row to modify");
        } else {
            String studentId = tblStudent.getValueAt(tb, 0).toString();
            String fullName = tblStudent.getValueAt(tb, 1).toString();
            String birthDay = tblStudent.getValueAt(tb, 2).toString();
            boolean gender = (tblStudent.getValueAt(tb, 3).toString().equals("Male")) ? true : false;
            String email = tblStudent.getValueAt(tb, 4).toString();
            String phone = tblStudent.getValueAt(tb, 5).toString();
            String address = tblStudent.getValueAt(tb, 6).toString();
            ClassModel clm = (ClassModel) tblStudent.getValueAt(tb, 7);
            new ViewEditStudent(this, true, new Student(studentId, fullName, birthDay, gender, email, phone, address, clm)).setVisible(true);
        }
    }//GEN-LAST:event_btnModifyCourse2ActionPerformed

    private void btnViewCourse2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewCourse2ActionPerformed
        int tb = tblStudent.getSelectedRow();
        if (tb == -1) {
            alert("select row to View");
        } else {
            String studentId = tblStudent.getValueAt(tb, 0).toString();
            String fullName = tblStudent.getValueAt(tb, 1).toString();
            String birthDay = tblStudent.getValueAt(tb, 2).toString();
            boolean gender = (tblStudent.getValueAt(tb, 3).toString().equals("Male")) ? true : false;
            String email = tblStudent.getValueAt(tb, 4).toString();
            String phone = tblStudent.getValueAt(tb, 5).toString();
            String address = tblStudent.getValueAt(tb, 6).toString();
            ClassModel clm = (ClassModel) tblStudent.getValueAt(tb, 7);
            new ViewViewStudent(this, true, new Student(studentId, fullName, birthDay, gender, email, phone, address, clm)).setVisible(true);
        }
    }//GEN-LAST:event_btnViewCourse2ActionPerformed

    private void btnDeleteCourse2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteCourse2ActionPerformed
        int tb = tblStudent.getSelectedRow();
        if (tb == -1) {
            alert("select row to remove");
        } else {
            int cf = JOptionPane.showConfirmDialog(this, "you are sure", "Remove Student", JOptionPane.YES_NO_OPTION);
            if (cf == JOptionPane.YES_OPTION) {
                String id = tblStudent.getValueAt(tb, 0).toString();
                boolean a = StudentDAO.deleteStudent(id);
                if (a) {
                    listStudent = StudentDAO.getAll();
                    alert("Remove Sucessfully");
                    this.loadTableStudent();
                } else {
                    alert("Fail");
                }
            }
        }
    }//GEN-LAST:event_btnDeleteCourse2ActionPerformed

    private void cbbClassItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbClassItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            String cls = cbbClass.getSelectedItem().toString();
            if (cls.equals("All Class")) {
                loadTableStudent();
                cbbClass.setSelectedItem("All Class");
            } else {
                List<Student> newlist = new ArrayList<Student>();
                listStudent = StudentDAO.getAll();
                for (Student st : listStudent) {
                    if (st.getClassModel().getClassName().equals(cls)) {
                        newlist.add(st);
                    }
                }
                DefaultTableModel model = new DefaultTableModel();
                model.setColumnIdentifiers(colStudent);
                for (Student st : newlist) {
                    String gender = (st.isGender()) ? "Male" : "Female";
                    model.addRow(new Object[]{st.getStudentId(), st.getFullName(), st.getBirthDay(), gender, st.getEmail(), st.getPhone(), st.getAddress(), st.getClassModel()});
                }
                tblStudent.setModel(model);
            }
        }
    }//GEN-LAST:event_cbbClassItemStateChanged

    private void cbbSelectCourseItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbSelectCourseItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            if (cbbSelectCourse.getSelectedIndex() != 0) {
                DefaultTableModel modeltbl = (DefaultTableModel) tblClass.getModel();
                modeltbl.setRowCount(0);
                Course cf = (Course) cbbSelectCourse.getSelectedItem();
                List<ClassModel> clm = ClassDAO.getClassByCourse(cf.getCourseID());
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                model.addElement("Select Class");
                for (ClassModel cl : clm) {
                    model.addElement(cl);
                    System.out.println(cl.getClassName());
                }
                cbbSelectClass.setModel(model);
            } else {
                cbbSelectClass.removeAllItems();
                DefaultTableModel model = (DefaultTableModel) tblClass.getModel();
                model.setRowCount(0);
            }
        }
    }//GEN-LAST:event_cbbSelectCourseItemStateChanged

    private void cbbSelectClassItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbSelectClassItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            loadTableClass();
        }
    }//GEN-LAST:event_cbbSelectClassItemStateChanged
    public void loadTableClass() {
        if (cbbSelectClass.getSelectedIndex() != 0) {
            ClassModel clm = (ClassModel) cbbSelectClass.getSelectedItem();
            List<Schedule> list = ScheduleDAO.getAll(clm.getClassId());
            DefaultTableModel model = (DefaultTableModel) tblClass.getModel();
            model.setRowCount(0);
            for (Schedule sc : list) {
                model.addRow(new Object[]{sc.getClassModel().getClassId(), sc.getClassModel(), sc.getDate()});
            }
        } else {
            DefaultTableModel model = (DefaultTableModel) tblClass.getModel();
            model.setRowCount(0);
        }
    }

    public void loadTableClassAtt() {
        if (cbbSelectClassAtt.getSelectedIndex() != 0) {
            ClassModel clm = (ClassModel) cbbSelectClassAtt.getSelectedItem();
            List<Schedule> list = ScheduleDAO.getAll(clm.getClassId());
            DefaultTableModel model = (DefaultTableModel) tblClassAtt.getModel();
            model.setRowCount(0);
            for (Schedule sc : list) {
                model.addRow(new Object[]{sc.getClassModel().getClassId(), sc.getClassModel(), sc.getDate()});
            }
        } else {
            DefaultTableModel model = (DefaultTableModel) tblClassAtt.getModel();
            model.setRowCount(0);
        }
    }
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        int tb = tblClass.getSelectedRow();
        if (tb == -1) {
            alert("select a row");
        } else {
            ClassModel clm = (ClassModel) tblClass.getValueAt(tb, 1);
            String date = tblClass.getValueAt(tb, 2).toString();
            List<Schedule> list = ScheduleDAO.getScheduleByDate(clm.getClassId(), date);
            new ViewViewClassScheduleTEST(this, true, clm, date, list).setVisible(true);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        if (cbbSelectClass.getSelectedIndex() > 0) {
            ClassModel clm = (ClassModel) cbbSelectClass.getSelectedItem();
            new ViewAddClassSchedule(this, true, clm).setVisible(true);
        } else {
            alert("select the class");
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        if (tblClass.getSelectedRow() != -1) {
            ClassModel clm = (ClassModel) cbbSelectClass.getSelectedItem();
            String date = tblClass.getValueAt(tblClass.getSelectedRow(), 2).toString();
            new ViewEditClassSchedule1(this, true, clm, date).setVisible(true);
        } else {
            alert("select the date schedule to edit");
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void cbbSelectCourseAttItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbSelectCourseAttItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            if (cbbSelectCourseAtt.getSelectedIndex() != 0) {
                DefaultTableModel modeltbl = (DefaultTableModel) tblClassAtt.getModel();
                modeltbl.setRowCount(0);
                Course cf = (Course) cbbSelectCourseAtt.getSelectedItem();
                List<ClassModel> clm = ClassDAO.getClassByCourse(cf.getCourseID());
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                model.addElement("Select Class");
                for (ClassModel cl : clm) {
                    model.addElement(cl);
                }
                cbbSelectClassAtt.setModel(model);
            } else {
                cbbSelectClassAtt.removeAllItems();
                DefaultTableModel model = (DefaultTableModel) tblClassAtt.getModel();
                model.setRowCount(0);
            }
        }
    }//GEN-LAST:event_cbbSelectCourseAttItemStateChanged

    private void cbbSelectClassAttItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbSelectClassAttItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            loadTableClassAtt();
        }
    }//GEN-LAST:event_cbbSelectClassAttItemStateChanged

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        int tb = tblClassAtt.getSelectedRow();
        if (tb == -1) {
            alert("select a row");
        } else {
            ClassModel clm = (ClassModel) tblClassAtt.getValueAt(tb, 1);
            String date = tblClassAtt.getValueAt(tb, 2).toString();
            List<Schedule> list = ScheduleDAO.getScheduleByDate(clm.getClassId(), date);
            new ViewViewAttendcance(this, true, clm, date, list).setVisible(true);
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        int tb = tblClassAtt.getSelectedRow();
        if (tb == -1) {
            alert("select a row");
        } else {
            ClassModel clm = (ClassModel) tblClassAtt.getValueAt(tb, 1);
            String date = tblClassAtt.getValueAt(tb, 2).toString();
            List<Schedule> list = ScheduleDAO.getScheduleByDate(clm.getClassId(), date);
            new ViewCheckAttendcance(this, true, clm, date, list).setVisible(true);
        }
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        int tb = tblClassAtt.getSelectedRow();
        if (tb == -1) {
            alert("select a row");
        } else {
            ClassModel clm = (ClassModel) tblClassAtt.getValueAt(tb, 1);
            String date = tblClassAtt.getValueAt(tb, 2).toString();
            List<Schedule> list = ScheduleDAO.getScheduleByDate(clm.getClassId(), date);
            new ViewEditAttendcance(this, true, clm, date, list).setVisible(true);
        }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void cbbCourseScheduleItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbCourseScheduleItemStateChanged
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            if (cbbCourseSchedule.getSelectedIndex() != 0) {
                txtSearchCourse.setText("");
                Course crs = (Course) cbbCourseSchedule.getSelectedItem();
                List<CourseSubject> list = new ArrayList<CourseSubject>();
                list = CousreSubjectDAO.getAll(crs);
                loadCourse(list);

            } else {
                model = new DefaultTableModel();
                model = (DefaultTableModel) tblCourse.getModel();
                model.setRowCount(0);
            }
        }
    }//GEN-LAST:event_cbbCourseScheduleItemStateChanged

    private void btnSearchCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchCourseActionPerformed
        String filter = (String) cbbFilterCourse.getSelectedItem();
        String key = txtSearchCourse.getText();
        if(!(key.trim()).equals("")){
            loadCourse(CousreSubjectDAO.search(filter,key));
        }
    }//GEN-LAST:event_btnSearchCourseActionPerformed
    public void loadCourse(List<CourseSubject> list) {
        model = new DefaultTableModel() {
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        model.setColumnIdentifiers(colCourseSubject);
//        csbj = CousreSubjectDAO.getAll();
        for (CourseSubject st : list) {
            model.addRow(new Object[]{st.getCourse().getCourseID(), st.getCourse(), st.getSubject().getSubjectId(), st.getSubject().getSubjectName(), st.getYear(), st.getHour()});
        }
        tblCourse.setModel(model);
    }

    public void loadTableStudent() {
        cbbClass.setSelectedItem("All Class");
        model = new DefaultTableModel() {
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        model.setColumnIdentifiers(colStudent);
//        listStudent = StudentDAO.getClassByCourse();
        for (Student st : listStudent) {
            String gender = (st.isGender()) ? "Male" : "Female";
            model.addRow(new Object[]{st.getStudentId(), st.getFullName(), st.getBirthDay(), gender, st.getEmail(), st.getPhone(), st.getAddress(), st.getClassModel()});
        }
        tblStudent.setModel(model);
    }

//    public void loadSchedule() {
//        model = new DefaultTableModel() {
//            public boolean isCellEditable(int row, int col) {
//                return false;
//            }
//        };
//        model.setColumnIdentifiers(colClass);
//        listClass = ClassDAO.getAll();
//        for (ClassModel cl : listClass) {
//            model.addRow(new Object[]{cl.getClassId(), cl.getClassName(), cl.getCourse(), cl.getStartYear(), cl.getFinishYear(), cl.getNoSemester()});
//        }
//        tblSchedule.setModel(model);
//    }
    public void alert(String ms) {
        JOptionPane.showMessageDialog(this, ms);
    }
    private DefaultTableModel model;
    private List<CourseSubject> csbj;
    private List<ClassModel> listClass;
    protected List<Student> listStudent = StudentDAO.getAll();
    private List<ClassModel> litsClass = ClassDAO.getAll();
    private String[] colCourseSubject = {"Course ID", "Course Name", "Subject ID", "Subject Name", "Year", "Hour a week"};
    private String[] colStudent = {"Student ID", "Full Name", "Birthday", "Gender", "Email", "Phone", "Address", "Class Name"};
    private String[] colClass = {"Class ID", "Class Name", "Course Name", "Start Year", "Finish Year", "No of Semester"};

//    phần test
    public void loadCbbCourse() {
        DefaultComboBoxModel cbb = new DefaultComboBoxModel();
        cbb.addElement("--Select Course--");
        List<Course> listcourse = CourseDAO.getAll();
        for (Course cf : listcourse) {
            cbb.addElement(cf);
        }
        cbbSelectCourse.setModel(cbb);
    }

    public void loadCbbCourseSchedule() {
        DefaultComboBoxModel cbb = new DefaultComboBoxModel();
        cbb.addElement("--Select Course--");
        List<Course> listcourse = CourseDAO.getAll();
        for (Course cf : listcourse) {
            cbb.addElement(cf);
        }
        cbbCourseSchedule.setModel(cbb);
    }

    public void loadCbbCourseAtt() {
        DefaultComboBoxModel cbb = new DefaultComboBoxModel();
        cbb.addElement("--Select Course--");
        List<Course> listcourse = CourseDAO.getAll();
        for (Course cf : listcourse) {
            cbb.addElement(cf);
        }
        cbbSelectCourseAtt.setModel(cbb);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddCourse;
    private javax.swing.JButton btnAddCourse2;
    private javax.swing.JButton btnDeleteCourse;
    private javax.swing.JButton btnDeleteCourse2;
    private javax.swing.JButton btnModifyCourse;
    private javax.swing.JButton btnModifyCourse2;
    private javax.swing.JButton btnSearchCourse;
    private javax.swing.JButton btnViewCourse;
    private javax.swing.JButton btnViewCourse2;
    private javax.swing.JComboBox cbbClass;
    private javax.swing.JComboBox cbbCourseSchedule;
    private javax.swing.JComboBox cbbFilterCourse;
    private javax.swing.JComboBox cbbSelectClass;
    private javax.swing.JComboBox cbbSelectClassAtt;
    private javax.swing.JComboBox cbbSelectCourse;
    private javax.swing.JComboBox cbbSelectCourseAtt;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTabbedPane jtabbed;
    private javax.swing.JLabel lblStaffName;
    private javax.swing.JTable tblClass;
    private javax.swing.JTable tblClassAtt;
    private javax.swing.JTable tblCourse;
    private javax.swing.JTable tblStudent;
    private javax.swing.JTextField txtSearchCourse;
    // End of variables declaration//GEN-END:variables
}
